//
// Created by Win10 on 2023/4/8.
//

#include "counting_sort.h"
#include <iostream>

using namespace std;

int n;
int c[10000]={0};

void counting_sort(int a[], int len) {
  for (int i = 0; i < len; i++) ++c[a[i]];
  int p=0;
  for (int i = 0; i < len; i++) {
    while(!c[p]) p++;
    a[i]=p;
    c[p]--;
  }
}

int main() {
  int a[10000]={0};
  printf("how many nums:");
  scanf("%d", &n);
  for (int i = 0; i < n; i++) printf("the \t%d num:",i+1),scanf("%d", &a[i]);
  counting_sort(a, n);
  printf("the sort result:\r\n");
  for (int i = 0; i < n; i++) printf("%d ", a[i]);
  printf("\n");
  return 0;
}